echo '#	This file is part of the software similarity tester SIM.'
echo '#	Written by Dick Grune, VU, Amsterdam; dick@dickgrune.com'
echo '#	$Id: Makefile,v 2.121 2020-12-16 20:44:26 dick Exp $'
echo '#'
echo ''
echo '#VERSION="-DVERSION=\"3.0.2 of 2017-12-16\""	# uncomment for public version'
echo ''
echo '#	E N T R Y   P O I N T S'
echo ''
echo 'help:'
echo '	@echo  '\''Entry points:'\'''
echo '	@echo  '\''test:           compile sim_c and run a simple test'\'''
echo '	@echo  '\'''\'''
echo '	@echo  '\''binaries:       create all binaries'\'''
echo '	@echo  '\''exes:           create executables in MSDOS'\'''
echo '	@echo  '\''install:        install all binaries'\'''
echo '	@echo  '\'''\'''
echo '	@echo  '\''view_man:       view sim.pdf'\'''
echo '	@echo  '\''lint:           lint sim sources'\'''
echo '	@echo  '\''simsim:         run sim_c on the sim sources'\'''
echo '	@echo  '\''view_SPC:       view the percentage computation document'\'''
echo '	@echo  '\''chklat:         do a LaTeX check on the .tex documents'\'''
echo '	@echo  '\'''\'''
echo '	@echo  '\''fresh:          remove created files'\'''
echo ''
echo '#'
echo '# When you modify any of the following macros, do '\''make clean'\'''
echo '#'
echo ''
echo '# System dependencies'
SRCDIR=../..''
echo 'SRCDIR =	..'
echo "#	=============== including" $(SRCDIR)/lib/sysidf.mk'' here
cat $(SRCDIR)/lib/sysidf.mk''
echo "#	=============== end of" $(SRCDIR)/lib/sysidf.mk''
echo 'include		$(SRCDIR)/lib/sysidf.mk'
echo ''
echo '# Compiling'
echo 'MEMORY =	-DMEMCHECK -DMEMCLOBBER'
echo 'CFLAGS =	$(VERSION) $(MEMORY) -O4 # -Dlint -DLIB # for all db active'
echo 'LIBFLAGS =	#'
echo 'LINTFLAGS =	-Dlint_test $(MEMORY) -h# -X'
echo 'LOADFLAGS =	-s#			# strip symbol table'
echo 'LOADER =	$(CC) $(LOADFLAGS)'
echo ''
echo '# Debugging'
echo 'CFLAGS +=	-DDEBUG'
echo ''
echo '#	T E S T   P A R A M E T E R S'
echo ''
echo '# Rumen Stevanov test'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-pPae -r4 -O -t4'
echo 'TEST_INP =	Contributors/Rumen_Stefanov/new/*.txt'
echo ''
echo '# slash test'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r24 -M clang.l pasclang.l "|" textlang.l'
echo 'TEST_INP ='
echo ''
echo '# -i option test'
echo 'TEST_LANG =	c'
echo 'TEST_OPT =	-f -r 20 -R -i <option-i.inp'
echo 'TEST_INP =	#'
echo ''
echo '# overlap  test, foo^100 vs. foo^150'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r50 -p'
echo 'TEST_OPT =	-r50'
echo 'TEST_INP =	Test_percentages/foo_100'
echo 'TEST_INP =	Test_percentages/foo_100 Test_percentages/foo_150'
echo ''
echo '# single file test'
echo 'TEST_LANG =	c'
echo 'TEST_OPT =	-r24 -M'
echo 'TEST_INP =	pass3.c pass3.c	# compares 1st to 2nd, then 2nd to 2nd'
echo ''
echo '# tight match test, foo_100 has exactly 100 tokens'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r50'
echo 'TEST_INP =	Test_percentages/foo_100'
echo ''
echo '# percentage test'
echo 'TEST_LANG =	c'
echo 'TEST_OPT =	-puae'
echo 'TEST_INP =	*.l'
echo ''
echo '# spaced word test'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r 5'
echo 'TEST_INP =	Testfiles/test_seplet'
echo ''
echo '# larger test'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r24 -M -puae'
echo 'TEST_INP = clang.c textlang.c'
echo 'TEST_INP = textlang.c clang.c javalang.c'
echo ''
echo '# test UTF-8 file names'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	Kor_test/한국어 Kor_test/한국어# '\''make'\'' cannot see these files'
echo 'TEST_INP =	#'
echo ''
echo '# test UTF-8 recursive file name test'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-R Kor_test'
echo 'TEST_INP =	#'
echo ''
echo '# test bad UTF-8 text'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r12 -MO -w80'
echo 'TEST_INP =	Testfiles/Korean1_bad.txt Testfiles/Korean1_bad2.txt'
echo ''
echo '# test UTF-8 text'
echo 'TEST_LANG =	text'
echo 'TEST_OPT =	-r12 -MO -w80'
echo 'TEST_INP =	Testfiles/Korean1.txt Testfiles/Korean2.txt'
echo ''
echo '# test'
echo 'TEST_LANG =	c'
echo 'TEST_OPT =	-r10 -MO'
echo 'TEST_INP =	pass2.c pass1.c'
echo ''
echo '#TEST_OPT =	-h'
echo ''
echo '#	M A I N   M O D U L E S'
echo ''
echo '#	Each module (set of programs that together perform some function)'
echo '#	has the following sets of files defined for it:'
echo '#		_SRC	the C-files from which the object files derive'
echo '#		_OBJ	object files'
echo '#		_HDR	header files and other include files'
echo '#		_GRB	garbage files produced by the module'
echo '#'
echo '#	(This is a feeble attempt at software-engineering a Makefile.)'
echo '#'
echo ''
echo 'test:		sim.res stream.res percentages.res version.res'
echo '		./sim_$(TEST_LANG)$(EXE) -v'
echo ''
echo ''
echo '#	B I N A R I E S'
echo ''
echo 'BINARIES =	sim_c$(EXE) sim_c++$(EXE) sim_java$(EXE) sim_pasc$(EXE) \'
echo '		sim_m2$(EXE) sim_lisp$(EXE) sim_mira$(EXE) sim_text$(EXE) \'
echo '		sim_8086$(EXE)'
echo ''
echo 'binaries:	$(BINARIES)#		# for *N?X'
echo 'exes:		binaries#		# for MSDOS'
echo 'test_exes:	binaries#		# for packCVS'
echo ''
echo '#	A U X I L I A R Y   M O D U L E S'
echo ''
echo '# Common modules:'
echo 'COM_SRC =	global.c token.c lex.c stream.c text.c tokenarray.c debug.c \'
echo '		utf8.c ForEachFile.c fname.c Malloc.c any_int.c'
echo 'COM_OBJ =	global.o token.o lex.o stream.o text.o tokenarray.o debug.o \'
echo '		utf8.o ForEachFile.o fname.o Malloc.o any_int.o'
echo 'COM_HDR =	global.h token.h lex.h stream.h text.h tokenarray.h debug.h \'
echo '		utf8.h ForEachFile.h fname.h Malloc.h any_int.h \'
echo '		lang.h \'
echo '		sortlist.spc sortlist.bdy system.par'
echo ''
echo '# C files for the abstract modules:'
echo 'ABS_SRC =	lang.c'
echo ''
echo '# The idf module:'
echo 'IDF_SRC =	idf.c'
echo 'IDF_OBJ =	idf.o'
echo 'IDF_HDR =	idf.h'
echo ''
echo '# The runs package:'
echo 'RUNS_SRC =	runs.c percentages.c'
echo 'RUNS_OBJ =	runs.o percentages.o'
echo 'RUNS_HDR =	runs.h percentages.h'
echo ''
echo '# The main program:'
echo 'MAIN_SRC =	sim.c options.c newargs.c hash.c compare.c add_run.c \'
echo '		pass1.c pass2.c pass3.c'
echo 'MAIN_OBJ =	sim.o options.o newargs.o hash.o compare.o add_run.o \'
echo '		pass1.o pass2.o pass3.o'
echo 'MAIN_HDR =	global.h options.h newargs.h hash.h compare.h add_run.h \'
echo '		pass1.h pass2.h pass3.h \'
echo '		debug.par settings.par'
echo ''
echo 'sim.o:	 	Makefile	# because of $(VERSION)'
echo ''
echo '# The similarity tester without the language part:'
echo 'SIM_SRC =	$(COM_SRC) $(IDF_SRC) $(RUNS_SRC) $(MAIN_SRC)'
echo 'SIM_OBJ =	$(COM_OBJ) $(IDF_OBJ) $(RUNS_OBJ) $(MAIN_OBJ)'
echo 'SIM_HDR =	$(COM_HDR) $(IDF_HDR) $(RUNS_HDR) $(MAIN_HDR)'
echo ''
echo ''
echo '#	L A N G U A G E S'
echo ''
echo '# The properties module:'
echo 'PROP_SRC =	properties.c'
echo 'PROP_OBJ =	properties.o'
echo 'PROP_HDR =	properties.h'
echo ''
echo '# The Generic Language module'
echo '#	variable:	GEN_LANG'
echo '#	entry point:	sim_gen$(EXE)'
echo '#	makes:		sim_$(GEN_LANG)$(EXE)'
echo ''
echo 'sim_gen.c:	$(GEN_LANG)lang.l'
echo '		$(LEX) -t $(GEN_LANG)lang.l >sim_gen.c'
echo ''
echo 'SIM_GEN_SRC =	$(SIM_SRC) $(PROP_SRC) sim_gen.c'
echo 'SIM_GEN_OBJ =	$(SIM_OBJ) $(PROP_OBJ) sim_gen.o'
echo ''
echo 'sim_gen$(EXE):	$(SIM_GEN_OBJ)'
echo '		$(LOADER) $(SIM_GEN_OBJ) -o $@'
echo '		mv sim_gen$(EXE) sim_$(GEN_LANG)$(EXE)'
echo '		rm -f sim_gen.[co]'
echo ''
echo '# The executables:				# using recursive make'
echo ''
echo 'LEX_HDR:	options.h token.h properties.h idf.h lex.h lang.h'
echo ''
echo 'sim_c$(EXE):	$(SIM_SRC) $(PROP_SRC) clang.l $(LEX_HDR)'
echo '		make GEN_LANG=c sim_gen$(EXE)'
echo ''
echo 'sim_text$(EXE):	$(SIM_SRC) $(PROP_SRC) textlang.l $(LEX_HDR)'
echo '		make GEN_LANG=text sim_gen$(EXE)'
echo ''
echo 'sim_c++$(EXE):	$(SIM_SRC) $(PROP_SRC) c++lang.l $(LEX_HDR)'
echo '		make GEN_LANG=c++ sim_gen$(EXE)'
echo ''
echo 'sim_java$(EXE):	$(SIM_SRC) $(PROP_SRC) javalang.l $(LEX_HDR)'
echo '		make GEN_LANG=java sim_gen$(EXE)'
echo ''
echo 'sim_pasc$(EXE):	$(SIM_SRC) $(PROP_SRC) pasclang.l $(LEX_HDR)'
echo '		make GEN_LANG=pasc sim_gen$(EXE)'
echo ''
echo 'sim_m2$(EXE):	$(SIM_SRC) $(PROP_SRC) m2lang.l $(LEX_HDR)'
echo '		make GEN_LANG=m2 sim_gen$(EXE)'
echo ''
echo 'sim_lisp$(EXE):	$(SIM_SRC) $(PROP_SRC) lisplang.l $(LEX_HDR)'
echo '		make GEN_LANG=lisp sim_gen$(EXE)'
echo ''
echo 'sim_mira$(EXE):	$(SIM_SRC) $(PROP_SRC) miralang.l $(LEX_HDR)'
echo '		make GEN_LANG=mira sim_gen$(EXE)'
echo ''
echo 'sim_8086$(EXE):	$(SIM_SRC) $(PROP_SRC) 8086lang.l $(LEX_HDR)'
echo '		make GEN_LANG=8086 sim_gen$(EXE)'
echo ''
echo '# Library files'
echo ''
cp -p $(SRCDIR)/lib/ForEachFile.h'' .
echo ''
cp -p $(SRCDIR)/lib/ForEachFile.c'' .
echo ''
cp -p $(SRCDIR)/lib/fname.h'' .
echo ''
cp -p $(SRCDIR)/lib/fname.c'' .
echo ''
cp -p $(SRCDIR)/lib/Malloc.h'' .
echo ''
cp -p $(SRCDIR)/lib/Malloc.c'' .
echo ''
cp -p $(SRCDIR)/lib/any_int.h'' .
echo ''
cp -p $(SRCDIR)/lib/any_int.c'' .
echo ''
cp -p $(SRCDIR)/lib/utf8.h'' .
echo ''
cp -p $(SRCDIR)/lib/utf8.c'' .
echo ''
cp -p $(SRCDIR)/lib/debug.h'' .
echo ''
cp -p $(SRCDIR)/lib/debug.c'' .
echo ''
echo '#	T E S T S'
echo ''
echo '# Some simple tests:'
echo '.PHONY:		sim.res percentages.res'
echo ''
echo 'sim.res:	sim_$(TEST_LANG)$(EXE) $(TEST_INP)'
echo '		./sim_$(TEST_LANG)$(EXE) $(TEST_OPT) $(TEST_INP)'
echo ''
echo 'stream.res:	sim_$(TEST_LANG)$(EXE)'
echo '		./sim_$(TEST_LANG)$(EXE) -- $(TEST_OPT) $(TEST_INP) >$@'
echo '		wc $@ $(TEST_INP)'
echo 'GARBAGE =	stream.res'
echo ''
echo 'PERC_TEST_EXE	=	sim_text$(EXE)'
echo 'PERC_TEST_FILES =	Test_percentages/foo_100 Test_percentages/foo_150'
echo 'PERC_TEST_EXE	=	sim_c$(EXE)'
echo 'PERC_TEST_FILES =	pasclang.l clang.l javalang.l'
echo 'percentages.res:$(PERC_TEST_EXE) $(PERC_TEST_FILES)'
echo '		@echo '\'''\'''
echo '		./$(PERC_TEST_EXE) -T -p $(PERC_TEST_FILES)'
echo '		@echo '\'''\'''
echo '		./$(PERC_TEST_EXE) -T -pa $(PERC_TEST_FILES)'
echo '		@echo '\'''\'''
echo '		./$(PERC_TEST_EXE) -T -pae $(PERC_TEST_FILES)'
echo ''
echo 'version.res:	sim_$(TEST_LANG)$(EXE)'
echo '		./sim_$(TEST_LANG)$(EXE) -v'
echo ''
echo ''
echo '# More simple tests, using the C version only:'
echo 'simsim:		sim_c$(EXE) $(SIM_SRC) $(PROP_SRC)'
echo '		./sim_c$(EXE) -fr 20 $(SIM_SRC) $(PROP_SRC)'
echo ''
echo '# Lint'
echo 'lint:		$(SIM_SRC) $(PROP_SRC) $(ABS_SRC) \'
echo '		$(SIM_HDR) $(PROP_HDR) $(ABS_HDR)'
echo '		$(LINT) $(LINTFLAGS) $(SIM_SRC) $(PROP_SRC) $(ABS_SRC)'
echo ''
echo ''
echo '#	O T H E R   E N T R I E S'
echo ''
echo '# Documentation'
echo ''
echo 'view_man:	sim.pdf'
echo '		$(VIEW_PDF) sim.pdf'
echo ''
echo '%.pdf:		%.tex'
echo '		$(LATEX) $< || log2errmsg <$*.log'
echo '		$(LATEX) $<'
echo '		$(LATEX) $<'
echo ''
echo 'SPC =		Similarity_Percentage_Computation'
echo 'view_SPC:	$(SPC).pdf'
echo '		$(VIEW_PDF) $(SPC).pdf'
echo 'DOCS +=		$(SPC).pdf'
echo ''
echo '# LaTeX checker'
echo 'chklat:'
echo '		chklat *.tex'
echo ''
echo '# Installation'
echo 'install_all:	install			# just a synonym'
echo 'install:	$(MAN1DIR)/sim.1 \'
echo '		$(BINDIR)/sim_c$(EXE) \'
echo '		$(BINDIR)/sim_text$(EXE) \'
echo '		$(BINDIR)/sim_c++$(EXE) \'
echo '		$(BINDIR)/sim_java$(EXE) \'
echo '		$(BINDIR)/sim_pasc$(EXE) \'
echo '		$(BINDIR)/sim_m2$(EXE) \'
echo '		$(BINDIR)/sim_lisp$(EXE) \'
echo '		$(BINDIR)/sim_mira$(EXE) \'
echo '		$(BINDIR)/sim_8086$(EXE)'
echo ''
echo '$(MAN1D)/sim.1:	sim.1'
echo '		$(COPY) sim.1 $@'
echo ''
echo '$(BINDIR)/sim_c$(EXE):	sim_c$(EXE)'
echo '		$(COPY) sim_c$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_text$(EXE):	sim_text$(EXE)'
echo '		$(COPY) sim_text$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_c++$(EXE):	sim_c++$(EXE)'
echo '		$(COPY) sim_c++$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_java$(EXE):	sim_java$(EXE)'
echo '		$(COPY) sim_java$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_pasc$(EXE):	sim_pasc$(EXE)'
echo '		$(COPY) sim_pasc$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_m2$(EXE):	sim_m2$(EXE)'
echo '		$(COPY) sim_m2$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_lisp$(EXE):	sim_lisp$(EXE)'
echo '		$(COPY) sim_lisp$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_mira$(EXE):	sim_mira$(EXE)'
echo '		$(COPY) sim_mira$(EXE) $@'
echo ''
echo '$(BINDIR)/sim_8086$(EXE):	sim_8086$(EXE)'
echo '		$(COPY) sim_8086$(EXE) $@'
echo ''
echo '# Clean-up'
echo ''
echo '.PHONY:		clean fresh'
echo 'clean:'
echo '		-rm -f *.o'
echo '		-rm -f $(GARBAGE)'
echo '		-rm -f *.aux *.log *.out'
echo '		-rm -f a.out a.exe sim.txt core mon.out'
echo ''
echo 'fresh:		clean'
echo '		-rm -f $(LIB_GRB)'
echo '		-rm -f *.exe'
echo ''
echo '#	D E P E N D E N C I E S'
echo ''
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'
echo 'ForEachFile.o: ForEachFile.c ForEachFile.h fname.h'
echo 'Malloc.o: Malloc.c any_int.h Malloc.h'
echo 'add_run.o: add_run.c global.h text.h runs.h percentages.h options.h \'
echo ' add_run.h'
echo 'any_int.o: any_int.c any_int.h'
echo 'compare.o: compare.c global.h text.h token.h tokenarray.h hash.h \'
echo ' properties.h options.h add_run.h compare.h debug.par'
echo 'count_sim_dup.o: count_sim_dup.c'
echo 'debug.o: debug.c debug.h'
echo 'fname.o: fname.c fname.h'
echo 'global.o: global.c global.h'
echo 'hash.o: hash.c system.par debug.par global.h options.h text.h Malloc.h \'
echo ' any_int.h token.h properties.h tokenarray.h hash.h'
echo 'idf.o: idf.c system.par token.h idf.h'
echo 'lang.o: lang.c token.h properties.h idf.h lex.h lang.h'
echo 'lex.o: lex.c lex.h'
echo 'newargs.o: newargs.c global.h ForEachFile.h fname.h Malloc.h newargs.h'
echo 'options.o: options.c options.h settings.par global.h'
echo 'pass1.o: pass1.c debug.par global.h text.h token.h tokenarray.h lang.h \'
echo ' options.h pass1.h'
echo 'pass2.o: pass2.c debug.par global.h token.h text.h lang.h pass2.h \'
echo ' sortlist.bdy'
echo 'pass3.o: pass3.c system.par debug.par global.h options.h fname.h utf8.h \'
echo ' text.h token.h runs.h percentages.h pass3.h'
echo 'percentages.o: percentages.c debug.par global.h text.h options.h Malloc.h \'
echo ' percentages.h sortlist.bdy'
echo 'properties.o: properties.c global.h options.h token.h properties.h'
echo 'runs.o: runs.c global.h text.h runs.h Malloc.h debug.par sortlist.bdy'
echo 'sim.o: sim.c global.h options.h newargs.h token.h tokenarray.h text.h \'
echo ' compare.h pass1.h pass2.h pass3.h percentages.h stream.h lang.h Malloc.h \'
echo ' any_int.h'
echo 'sim_gen.o: sim_gen.c global.h options.h token.h properties.h idf.h lex.h \'
echo ' lang.h'
echo 'stream.o: stream.c system.par global.h token.h lang.h fname.h stream.h'
echo 'text.o: text.c stream.h Malloc.h text.h'
echo 'token.o: token.c token.h any_int.h'
echo 'tokenarray.o: tokenarray.c global.h Malloc.h token.h tokenarray.h'
echo 'utf8.o: utf8.c utf8.h'
